package Lambda.Consumer;


import java.util.function.Consumer;

public class Consumerdemo3 {
    private static void printInfo(String[] arr, Consumer<String> con1,Consumer<String> con2){
        for (String message : arr) {
            con1.andThen(con2).accept(message);
        }
    }

    public static void main(String[] args) {
        String[] arr={"赵丽颖，女","科比，男","詹姆斯，男"};
        printInfo(arr,
                (message)->{
                    //利用split()切割方法，获取姓名和性别
                    String s=message.split("，")[0];
                    System.out.print("姓名:"+s+" ");
                },
                (message)->{
                    String s = message.split("，")[1];
                    System.out.println("性别:"+s);
                });
    }
}
